import java.util.Scanner;

public class work {
    public static void main(String[] args) {
        String S = "ANQNANBNQNANQNQNBNINQNQNANQNINANQNANBNQNANQNQNBNINQNQNANQNINBNQNANBNQN";
        int maxScore = 0; // 用于记录最大分数
        String bestSubstring = ""; // 用于记录最优子串

        // 枚举所有可能的子串
        for (int len = 1; len <= 10; len++) { // 子串长度不超过10
            for (int i = 0; i <= S.length() - len; i++) {
                String substring = S.substring(i, i + len); // 获取子串
                int count = countOccurrences(S, substring); // 计算子串在S中的出现次数
                int score = len * count; // 计算分数

                // 更新最优子串
                if (score > maxScore || (score == maxScore && substring.compareTo(bestSubstring) < 0)) {
                    maxScore = score;
                    bestSubstring = substring;
                }
            }
        }

        System.out.println(bestSubstring); // 输出结果
    }

    // 计算子串在字符串S中的出现次数
    static int countOccurrences(String S, String substring) {
        int count = 0;
        int index = 0;
        while ((index = S.indexOf(substring, index)) != -1) {
            count++;
            index += substring.length(); // 移动到子串的下一个位置
        }
        return count;
    }


}
